package cn.itcast.wushangxiantu.Activity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

import cn.itcast.wushangxiantu.BaseAdapter.GuoZhanViewPagerAdapter;
import cn.itcast.wushangxiantu.Fragment.guozhanshenqin.ChuangJianGuoJiaFragment;
import cn.itcast.wushangxiantu.Fragment.guozhanshenqin.GuoJiaLieBiaoFragment;
import cn.itcast.wushangxiantu.Fragment.guozhanshenqin.ShenQinFragment;
import cn.itcast.wushangxiantu.R;

public class GuoZhanShenQinActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private TabLayout tabLayout;
    private List<Fragment> viewList = new ArrayList<>();
    private List<String> titleList = new ArrayList<>();
    private GuoZhanViewPagerAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guo_zhan_shen_qin);
        initView();
    }

    private void initView() {
        viewPager = (ViewPager) findViewById(R.id.viewPager);
        tabLayout = (TabLayout) findViewById(R.id.tabLayout);
        titleList.add("创建仙盟");
        titleList.add("仙盟列表");
        titleList.add("申请列表");
        addView();
    }
    private void addView() {
        viewList.add(new ChuangJianGuoJiaFragment(GuoZhanShenQinActivity.this));
        viewList.add(new GuoJiaLieBiaoFragment(GuoZhanShenQinActivity.this));
        viewList.add(new ShenQinFragment(GuoZhanShenQinActivity.this));

        adapter = new GuoZhanViewPagerAdapter(getSupportFragmentManager(), viewList, titleList);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
    }
}